import axios from 'axios'
import './evaluate.css'
import { React, useState, useEffect } from "react";
import InterIP from "../../IP/IP";
import { Rate, Empty } from 'antd';
import 'antd/dist/antd.css';

export default function Evaluate() {
  const [evaluate, setEvaluate] = useState([]);
  useEffect(() => {
    let IP = InterIP().props.children;
    let productId = localStorage.getItem('productId')
    axios.post('http://' + IP + ':3000/index/product/evaluate', {
      product_id: productId,
    }).then((res) => {
      setEvaluate((evaluate) => evaluate = res.data);
    })
  }, [])
  return (
    <div className="evaluate">
      {(evaluate.length) ? evaluate.map((data, key) => <div className="product_evaluate" key={key}><div className="product_evaluate_user"><div><img src={data.user_header} alt="" /></div><h4>{data.user_name}</h4></div><div className="product_evaluate_content"><div><div><Rate disabled defaultValue={data.user_score} /></div><div>{data.evaluate_time}</div></div><div>{data.evaluate_text}</div></div></div>) : <Empty description='暂无评价'></Empty>}
    </div>
  )
}
